package com.nana.framework.MVC.view
{
	import com.nana.framework.ui.PSprite;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	
	public class AppContainer extends PSprite
	{
		private var _appStage:Stage;
		private var _mainSprite:Sprite;
		
		private var _sceneLayer:PSprite;	// 游戏主要场景
		private var _uiLayer:PSprite;		// 用户交互元素
		private var _panelLayer:PSprite;	// 面板层
		private var _popUpLayer:PSprite;	// 弹框
		private var _tipLayer:PSprite;		// 提示
		
		public function AppContainer()
		{
			super();
		}
		
		public function init(aStage:Stage, main:Sprite):void
		{
			if (aStage == null) {
				throw new Error ("stage is null! Please set the stage property to App first!");
			}
			_appStage = aStage;
			_mainSprite = main;
			
			_sceneLayer = new PSprite;
			aStage.addChildAt(this.sceneLayer, 0);
			_uiLayer = new PSprite;
			_mainSprite.addChild(this.uiLayer);
			_panelLayer = new PSprite;
			_mainSprite.addChild(this.panelLayer);
			_tipLayer = new PSprite;
			_mainSprite.addChild(this.tipLayer);
			_popUpLayer = new PSprite;
			_mainSprite.addChild(this.popUpLayer);
		}
		
		public function swapUIAndPanel():void{
			_mainSprite.swapChildren(_uiLayer, _panelLayer);
		}
		
		public function get panelOnUI():Boolean{
			if (_mainSprite.getChildIndex(_panelLayer) > _mainSprite.getChildIndex(_uiLayer)){
				return true;
			}
			return false;
		}

		public function get sceneLayer():PSprite
		{
			return _sceneLayer;
		}

		public function get popUpLayer():PSprite
		{
			return _popUpLayer;
		}

		public function get panelLayer():PSprite
		{
			return _panelLayer;
		}

		public function get uiLayer():PSprite
		{
			return _uiLayer;
		}

		public function get tipLayer():PSprite
		{
			return _tipLayer;
		}


	}
}